package com.thiswhyme.swagger.service2.controller;

import com.thiswhyme.common.response.ResponseVo;
import com.thiswhyme.swagger.service2.dto.ReqDto;
import com.thiswhyme.swagger.service2.dto.UserDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

/**
 * Created by thiswhyme on 2020/6/4.
 */
@RestController
@RequestMapping("/swaggertwo")
@Api(tags = "【用户】")
public class SwaggerTwoController {

    @ApiOperation("查询用户信息")
    @GetMapping("/queryUserInfo")
    public ResponseVo<UserDto> queryUserInfo(@RequestParam @ApiParam(value = "用户ID") Integer userId) {
        return ResponseVo.success(new UserDto().setName("测试用户").setUserId(userId));
    }

    @ApiOperation("添加用户")
    @PostMapping("/addUser")
    public ResponseVo<String> addUser(@RequestBody UserDto req) {
        return ResponseVo.success(req.getUserId() + ": 添加成功");
    }

    @ApiOperation("更新用户")
    @PutMapping("/putUser")
    public ResponseVo<String> putUser(@RequestBody ReqDto req) {
        return ResponseVo.success(req.getUserId() + ": 更新成功");
    }

    @ApiOperation("删除用户")
    @DeleteMapping("/deleteUser")
    public ResponseVo<String> deleteUser(@RequestParam @ApiParam(value = "用户ID") Integer userId) {
        return ResponseVo.success(userId + ": 删除成功");
    }
}
